import LGXCOM from '../../common/common'
var ArrowKeyTranslateSvc = {}

ArrowKeyTranslateSvc.actToArrowKey = function (dataManger, keyCode) {
    let offsetPt = { x: 0, y: 0 };
    let scaling = dataManger.getScaling();
    const keyTransGap = 5;
    let gap = keyTransGap / scaling;
    switch (keyCode) {
        case "ArrowLeft":
            offsetPt.x = -gap;
            break;

        case "ArrowRight":
            offsetPt.x = gap;
            break;

        case "ArrowUp":
            offsetPt.y = gap;
            break;

        case "ArrowDown":
            offsetPt.y = -gap;
            break;
    }

    this.modifyCurentSelGraphs(dataManger,offsetPt);
}

ArrowKeyTranslateSvc.modifyCurentSelGraphs = function(dataManger,offsetPt){
    let pGraph = dataManger.getCurentGraph();
    if (!pGraph){
        return ;
    }
    var cmdinfo = new LGXCOM.LXModifyCMDInfo();
    cmdinfo.mapscale = dataManger.getMapScale();
    cmdinfo.scaling = dataManger.getScaling();
    var failed = pGraph.modifyByOffset(offsetPt, cmdinfo);
    return 0;
}

export { ArrowKeyTranslateSvc }